package com.woniu.cinema.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.woniu.common.annotation.Log;
import com.woniu.common.core.controller.BaseController;
import com.woniu.common.core.domain.AjaxResult;
import com.woniu.common.enums.BusinessType;
import com.woniu.cinema.domain.MovieArea;
import com.woniu.cinema.service.MovieAreaService;
import com.woniu.common.utils.poi.ExcelUtil;
import com.woniu.common.core.page.TableDataInfo;

/**
 * 影片地区Controller
 *
 * @author yy
 * @date 2023-09-27
 */
@RestController
@RequestMapping("/cinema/moviearea")
public class MovieAreaController extends BaseController
{
    @Autowired
    private MovieAreaService movieAreaService;

    /**
     * 查询影片地区列表
     */
    @GetMapping("/list")
    public TableDataInfo list(MovieArea movieArea)
    {
        startPage();
        List<MovieArea> list = movieAreaService.selectMovieAreaList(movieArea);
        return getDataTable(list);
    }

    @GetMapping("web/list")
    public TableDataInfo weblist(MovieArea movieArea)
    {
        startPage();
        List<MovieArea> list = movieAreaService.selectMovieAreaList(movieArea);
        return getDataTable(list);
    }
    /**
     * 导出影片地区列表
     */
    @Log(title = "影片地区", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MovieArea movieArea)
    {
        List<MovieArea> list = movieAreaService.selectMovieAreaList(movieArea);
        ExcelUtil<MovieArea> util = new ExcelUtil<MovieArea>(MovieArea.class);
        return util.exportExcel(list, "moviearea");
    }

    /**
     * 获取影片地区详细信息
     */
    @GetMapping(value = "/{areaId}")
    public AjaxResult getInfo(@PathVariable("areaId") Integer areaId)
    {
        return AjaxResult.success(movieAreaService.selectMovieAreaById(areaId));
    }

    /**
     * 新增影片地区
     */
    @Log(title = "影片地区", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MovieArea movieArea)
    {
        return toAjax(movieAreaService.insertMovieArea(movieArea));
    }

    /**
     * 修改影片地区
     */
    @Log(title = "影片地区", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MovieArea movieArea)
    {
        return toAjax(movieAreaService.updateMovieArea(movieArea));
    }

    /**
     * 删除影片地区
     */
    @Log(title = "影片地区", businessType = BusinessType.DELETE)
	@DeleteMapping("/{areaIds}")
    public AjaxResult remove(@PathVariable Integer[] areaIds)
    {
        return toAjax(movieAreaService.deleteMovieAreaByIds(areaIds));
    }
}
